package com.bosssoft.goods.domain.bean;

import com.bosssoft.goods.domain.bo.BrandCatBO;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.Setter;

import java.util.*;

/**
 * 商品品牌
 * @author Fang_Sir
 * @date 2021-04-13
 */
@Getter
@Setter
public class GoodsBrand {
    private int id;
    private String name;
    private List<BrandCatBO> category;

    public List<List<Map<String,Object>>> getCategory() {
        if(category == null) {
            return new ArrayList<>();
        }
        ArrayList<List<Map<String,Object>>> list = new ArrayList<>();
        category.forEach(e -> {
            ArrayList<Map<String, Object>> item = new ArrayList<>();
            Map<String, Object> cat0 = new HashMap<>();
            cat0.put("id", e.getId0());
            cat0.put("name", e.getName0());
            cat0.put("level", 0);
            Map<String, Object> cat1 = new HashMap<>();
            cat1.put("id", e.getId1());
            cat1.put("name", e.getName1());
            cat1.put("level", 1);
            Map<String, Object> cat2 = new HashMap<>();
            cat2.put("id", e.getId2());
            cat2.put("name", e.getName2());
            cat2.put("level", 2);
            item.add(cat0);
            item.add(cat1);
            item.add(cat2);
            list.add(item);
        });
        return list;
    }

    @JsonIgnore
    private Date createTime;

    @JsonIgnore
    private int uid;
}
